<#include "../common/common.ftl"/>
<table class="layui-table">
    <tr class="layui-bg-gray">
        <th style="text-align: center;width: 3%;" rowspan="2">序号</th>
        <th style="text-align: center;" rowspan="2">安置项目</th>
        <th style="text-align: center;" colspan="5">安置房源信息</th>
        <th style="text-align: center;width: 16%;" rowspan="2">操作</th>
    </tr>
    <tr class="layui-bg-gray">
        <th style="text-align: center;">房源信息</th>
        <th style="text-align: center;">房屋类型</th>
        <th style="text-align: center;">房屋户型</th>
        <th style="text-align: center;">建筑面积(使用应安置面积)</th>
        <th style="text-align: center;">房源性质</th>

    </tr>
<#list houseList as house>
    <#assign storageRoom=resultMap[house.id?c]/>
    <tr>
        <td style="text-align: center;">${house_index+1}</td>
        <td style="text-align: center;">${(house.azProject.projectName)!}</td>
        <td style="text-align: center;">${(house.houseNumStr)!}【${(house.floor)!}层】</td>
        <td style="text-align: center;">${(houseTypeMap[house.houseType].name)!}</td>
        <td style="text-align: center;">${(house.memo)!}</td>
        <td style="text-align: center;">${(house.buildArea)!}</td>
        <td style="text-align: center;">${(houseHoldMap[house.houseHold].name)!}</td>

        <th style="text-align: center;">
            <#if (contract.chooseHouseStatus == 1)>
                <#if !(storageRoom.id??)>
                    <a class="layui-btn layui-btn-xs layui-btn-danger houseDelete" buildNum="${(house.buildNum)!}"
                       houseNum="${(house.houseNum)!}" houseId="${house.id}"><i
                                class="layui-icon layui-icon-delete"></i>撤销房源</a>
                </#if>
            </#if>
        </th>
    </tr>
</#list>
    <tr class="layui-bg-gray">
        <td colspan="5" style="text-align: right;">合计：</td>
        <td colspan="4" style="text-align: left;">
            <span class="jmdf-color-red">
                换购所需面积（住宅、店面、车位）：${(contract.chooseHouseAreaTotal + contract.dmResultArea + contract.carLotTotalZhArea)!}
                剩余可安置面积
                【${(contract.limitHouseAreaTotal-contract.chooseHouseAreaTotal - contract.dmResultArea - contract.carLotTotalZhArea)!}】
            </span>
        </td>
    </tr>
</table>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['jquery', 'layer', 'jmdf'], function () {
        var $ = layui.jquery, layer = layui.layer, jmdf = layui.jmdf;

        $(".houseDelete").click(function () {
            var obj = $(this);
            layer.open({
                title: false,
                shade: 0.5,
                content: "确定撤销【" + obj.attr("buildNum") + "幢" + obj.attr("houseNum") + "】房源吗？",
                btn: ['确定', '取消'],
                closeBtn: 0,
                btnAlign: 'c'
                ,
                yes: function (index) {
                    $.get("houseDelete", {
                        contractId: "${(contract.id)!}",
                        houseId: obj.attr("houseId"),
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            layer.msg(data.message, {anim: 0, icon: 1, time: 1000});
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 2000});
                        }
                        loadSelectHouseInfo("${(contract.id)!}");
                    })
                }
            });
        });

        $(".storageRoomDelete").click(function () {
            var obj = $(this);
            layer.open({
                title: false,
                shade: 0.5,
                content: "确定撤销【" + obj.attr("buildNum") + "幢" + obj.attr("houseNum") + "】储藏室吗？",
                btn: ['确定', '取消'],
                closeBtn: 0,
                btnAlign: 'c'
                ,
                yes: function (index) {
                    $.get("storageRoomDelete", {
                        storageRoomId: obj.attr("storageRoomId"),
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            layer.msg(data.message, {anim: 0, icon: 1, time: 1000});
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 2000});
                        }
                        loadSelectHouseInfo("${(contract.id)!}");
                    })
                }
            });
        });

        $(".storageRoomAdd").click(function () {
            var houseId = $(this).attr("houseId");
            jmdf.view("storageRoomList?type=2&houseId=" + houseId, "80");
        })

        $(".setDisplaceType").click(function () {
            var houseId = $(this).attr("houseId");
            jmdf.minForm("setDisplaceType?contractId=${(contract.id)!}&houseId=" + houseId, "600px", "600px");
        })
    });
</script>